package com.hua.yuan.ui.data;

import com.hua.yuan.http.Actions;
import com.hua.yuan.http.GetDataTask;
import com.hua.yuan.http.RequestPramsMap;
import com.hua.yuan.http.ShowUrl;
import com.zhy.http.okhttp.callback.StringCallback;

import java.util.Map;

/**
 * Created by huangyang on 2018/5/27.
 * 支付接口
 */

public class PlayDataRequest {


    /**
     * 支付的接口
     *
     * @param token          token
     * @param type           支付类型（alipay:支付宝,tenpay:财付通,qqpay：QQ钱包，wxpay：微信支付）
     * @param name           商品名称
     * @param money          商品金额
     * @param buy_type       购买的类型，1代表买电影，2代表买代币
     * @param id             电影id， 如果是购买电影，必传
     * @param num            代币数量， 如果是购买代币，必传
     * @param stringCallback 结果
     */

    public static void payMoney(String token,
                                String type,
                                String name,
                                String money,
                                String buy_type,
                                String id,
                                String num,
                                StringCallback stringCallback) {


        Map<String, String> hashMap = new RequestPramsMap.Builder()
                .put("token", token)
                .put("type", type)
                .put("name", name)
                .put("money", money)
                .put("buy_type", buy_type)
//                .put("id", id)
                .put("num", num)
                .getHashMap();
        GetDataTask.getDataPost(Actions.pay, hashMap, stringCallback);

        ShowUrl.createPostUrl(Actions.pay, hashMap);


    }


    /**
     * 查询钱数的接口
     *
     * @param token          token
     * @param stringCallback 结果
     */
    public static void queryMoney(String token, StringCallback stringCallback) {

        Map<String, String> hashMap = new RequestPramsMap.Builder()
                .put("token", token)
                .getHashMap();
        GetDataTask.getDataPost(Actions.query_money, hashMap, stringCallback);

    }

    /**
     * 扣代币
     *
     * @param token          token
     * @param id             电影的id
     * @param stringCallback 结果
     */
    public static void deleteMoney(String token, String id, StringCallback stringCallback) {
        Map<String, String> hashMap = new RequestPramsMap.Builder()
                .put("token", token)
                .put("id", id)
                .getHashMap();
        GetDataTask.getDataPost(Actions.deduct_money, hashMap, stringCallback);
    }

    public static void deleteMoney(boolean isTuji, String token, String id, StringCallback stringCallback) {
        if (isTuji) {
            Map<String, String> hashMap = new RequestPramsMap.Builder()
                    .put("token", token)
                    .put("atlas_id", id)
                    .getHashMap();
            GetDataTask.getDataPost(Actions.PICTURE_DEDUCT_MONEY, hashMap, stringCallback);
        }else{
            Map<String, String> hashMap = new RequestPramsMap.Builder()
                    .put("token", token)
                    .put("id", id)
                    .getHashMap();
            GetDataTask.getDataPost(Actions.deduct_money, hashMap, stringCallback);
        }
    }

}
